package com.easy.service.impl;

import com.easy.bean.Notion;
import com.easy.mapper.NotionDao;
import com.easy.service.NotionService;
import com.easy.util.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NotionServiceImpl implements NotionService {

    @Autowired
    NotionDao notionDao;

    @Override
    public Notion add(Notion notion){
        notionDao.add(notion);
        Notion result=notionDao.one(notion.getId());
        return result;
    }

    @Override
    public int del(Integer id){
        return notionDao.del(id);
    }

    @Override
    public Notion edit(Notion notion){
        notionDao.edit(notion);
        Notion result=notionDao.one(notion.getId());
        return result;
    }

    @Override
    public Notion one(Integer id){
        return notionDao.one(id);
    }

    @Override
    public List<Notion> all(Notion notion){
        return notionDao.all(notion);
    }

    @Override
    public void page(Page page, Notion notion){
        int count=notionDao.pageCount(notion);
        Object data=notionDao.page(page,notion);
        page.setCount(count);
        page.setData(data);
    }
}
